package com.mdxx.xczd;

import org.greenrobot.eventbus.EventBus;
import org.junit.Test;

import rx.Observable;
import rx.Observer;
import rx.Subscriber;
import rx.functions.Func1;

/**
 * Created by MD-02 on 2017/3/3.
 */

public class RxTest1 {

    @Test
    public void main(){


        Observable<Integer> value = Observable.create(new Observable.OnSubscribe<Integer>(){
            public void call(Subscriber<? super Integer> o){
                o.onNext(0);
                o.onNext(1);
                o.onNext(10);
                o.onNext(2);
                o.onCompleted();
            }
        });


        Observer<Boolean> observer = new Observer<Boolean>(){
            @Override
            public void onCompleted() {
                System.out.println("onCompleted");
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(Boolean integer) {
                System.out.println(integer);
            }
        };

       /* value.exists(new Func1<Integer, Boolean>() {
            @Override
            public Boolean call(Integer integer) {

                return integer.intValue()%2 == 0;
            }
        }).subscribe(observer);*/

        value.contains(11).subscribe(observer);


    }
}
